package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.BaiKeBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.TListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.GetBaiKeInfoModel;
import cn.edu.neusoft.wuguangsheng.flowerimpression.service.Service;

public class BaiKeInfoActivity extends BaseActivity implements View.OnClickListener{
    private String enc_id;
    ImageView baikeinfo_fh;
    ImageView baikeinfo_tuku;

    ImageView baikeinfo_img;
    TextView baikeinfo_name;
    TextView baikeinfo_bieming,baikeinfo_fenlei,baikeinfo_shenghuaqi,baikeinfo_keshu,baikeinfo_jiejian;

    Button baikeinfo_btn_jieshao,baikeinfo_btn_xingtaitezhen,baikeinfo_btn_shengtaixixing,baikeinfo_btn_zaipeijishu,baikeinfo_btn_yangzhifangfa;
    Button baikeinfo_btn_fanzhifangshi,baikeinfo_btn_binghaifangzhi,baikeinfo_btn_pinghzongfenlei,baikeinfo_btn_fenbuquyu;
    Button baikeinfo_btn_zuoyongyongtu,baikeinfo_btn_yuanlingyongtu,baikeinfo_btn_wenhuabeijing,baikeinfo_btn_huayu;

    private String jieshao,xingtaitezhen,shengtaixixing,zaipeijishu,yangzhifangfa,fanzhifangshi,binghaifangzhi,pingzhongfenlei,fenbuquyu;
    private String zuoyongyongtu,yuanlingyongtu,wenhuabeijing,huayu;

    @Override
    void initView() {

        setLayout_file(R.layout.activity_bai_ke_info);
        enc_id = getIntent().getStringExtra("enc_id");
        baikeinfo_fh = (ImageView)findViewById(R.id.baikeinfo_fh);
        baikeinfo_tuku = (ImageView)findViewById(R.id.baikeinfo_tuku);
        baikeinfo_img = (ImageView)findViewById(R.id.baikeinfo_img);
        baikeinfo_name = (TextView)findViewById(R.id.baikeinfo_name);
        baikeinfo_bieming = (TextView)findViewById(R.id.baikeinfo_bieming);
        baikeinfo_fenlei = (TextView)findViewById(R.id.baikeinfo_fenlei);
        baikeinfo_shenghuaqi = (TextView)findViewById(R.id.baikeinfo_shenghuaqi);
        baikeinfo_keshu = (TextView)findViewById(R.id.baikeinfo_keshu);
        baikeinfo_jiejian = (TextView)findViewById(R.id.baikeinfo_jiejian);
       // Toast.makeText(BaiKeInfoActivity.this,enc_id,Toast.LENGTH_SHORT).show();

        baikeinfo_btn_jieshao = (Button)findViewById(R.id.baikeinfo_btn_jieshao);
        baikeinfo_btn_xingtaitezhen = (Button)findViewById(R.id.baikeinfo_btn_xingtaitezhen);
        baikeinfo_btn_shengtaixixing = (Button)findViewById(R.id.baikeinfo_btn_shengtaixixing);
        baikeinfo_btn_zaipeijishu = (Button)findViewById(R.id.baikeinfo_btn_zaipeijishu);
        baikeinfo_btn_yangzhifangfa = (Button)findViewById(R.id.baikeinfo_btn_yangzhifangfa);
        baikeinfo_btn_fanzhifangshi = (Button)findViewById(R.id.baikeinfo_btn_fanzhifangshi);
        baikeinfo_btn_binghaifangzhi = (Button)findViewById(R.id.baikeinfo_btn_binghaifangzhi);
        baikeinfo_btn_pinghzongfenlei = (Button)findViewById(R.id.baikeinfo_btn_pinghzongfenlei);
        baikeinfo_btn_fenbuquyu = (Button)findViewById(R.id.baikeinfo_btn_fenbuquyu);
        baikeinfo_btn_zuoyongyongtu = (Button)findViewById(R.id.baikeinfo_btn_zuoyongyongtu);
        baikeinfo_btn_yuanlingyongtu = (Button)findViewById(R.id.baikeinfo_btn_yuanlingyongtu);
        baikeinfo_btn_wenhuabeijing = (Button)findViewById(R.id.baikeinfo_btn_wenhuabeijing);
        baikeinfo_btn_huayu = (Button)findViewById(R.id.baikeinfo_btn_huayu);

    }

    @Override
    void initEvent() {
        baikeinfo_fh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        baikeinfo_tuku.setOnClickListener(this);
        baikeinfo_btn_jieshao.setOnClickListener(this);
        baikeinfo_btn_xingtaitezhen.setOnClickListener(this);
        baikeinfo_btn_shengtaixixing.setOnClickListener(this);
        baikeinfo_btn_zaipeijishu.setOnClickListener(this);
        baikeinfo_btn_yangzhifangfa.setOnClickListener(this);
        baikeinfo_btn_fanzhifangshi.setOnClickListener(this);
        baikeinfo_btn_binghaifangzhi.setOnClickListener(this);
        baikeinfo_btn_pinghzongfenlei.setOnClickListener(this);
        baikeinfo_btn_fenbuquyu.setOnClickListener(this);
        baikeinfo_btn_zuoyongyongtu.setOnClickListener(this);
        baikeinfo_btn_yuanlingyongtu.setOnClickListener(this);
        baikeinfo_btn_wenhuabeijing.setOnClickListener(this);
        baikeinfo_btn_huayu.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.baikeinfo_tuku:
                Intent intent = new Intent(BaiKeInfoActivity.this,BaiKeInfoPhotoListActivity.class);
                intent.putExtra("enc_id",enc_id);
                startActivity(intent);
                break;
            case R.id.baikeinfo_btn_jieshao:
                String title = baikeinfo_btn_jieshao.getText().toString().trim();
                Intent intent1 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent1.putExtra("title",title);
                intent1.putExtra("content",jieshao);
                startActivity(intent1);
                break;
            case R.id.baikeinfo_btn_xingtaitezhen:
                Intent intent2 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent2.putExtra("title",baikeinfo_btn_xingtaitezhen.getText().toString());
                intent2.putExtra("content",xingtaitezhen);
                startActivity(intent2);
                break;
            case R.id.baikeinfo_btn_shengtaixixing:
                Intent intent3 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent3.putExtra("title",baikeinfo_btn_shengtaixixing.getText().toString());
                intent3.putExtra("content",shengtaixixing);
                startActivity(intent3);
                break;
            case R.id.baikeinfo_btn_zaipeijishu:
                Intent intent4 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent4.putExtra("title",baikeinfo_btn_zaipeijishu.getText().toString());
                intent4.putExtra("content",zaipeijishu);
                startActivity(intent4);
                break;
            case R.id.baikeinfo_btn_yangzhifangfa:
                Intent intent5 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent5.putExtra("title",baikeinfo_btn_yangzhifangfa.getText().toString());
                intent5.putExtra("content",yangzhifangfa);
                startActivity(intent5);
                break;
            case R.id.baikeinfo_btn_fanzhifangshi:
                Intent intent6 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent6.putExtra("title",baikeinfo_btn_fanzhifangshi.getText().toString());
                intent6.putExtra("content",fanzhifangshi);
                startActivity(intent6);
                break;
            case R.id.baikeinfo_btn_binghaifangzhi:
                Intent intent7 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent7.putExtra("title",baikeinfo_btn_binghaifangzhi.getText().toString());
                intent7.putExtra("content",binghaifangzhi);
                startActivity(intent7);
                break;
            case R.id.baikeinfo_btn_pinghzongfenlei:
                Intent intent8 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent8.putExtra("title",baikeinfo_btn_pinghzongfenlei.getText().toString());
                intent8.putExtra("content",pingzhongfenlei);
                startActivity(intent8);
                break;
            case R.id.baikeinfo_btn_fenbuquyu:
                Intent intent9 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent9.putExtra("title",baikeinfo_btn_fenbuquyu.getText().toString());
                intent9.putExtra("content",fenbuquyu);
                startActivity(intent9);
                break;
            case R.id.baikeinfo_btn_zuoyongyongtu:
                Intent intent10 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent10.putExtra("title",baikeinfo_btn_zuoyongyongtu.getText().toString());
                intent10.putExtra("content",zuoyongyongtu);
                startActivity(intent10);
                break;
            case R.id.baikeinfo_btn_yuanlingyongtu:
                Intent intent11 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent11.putExtra("title",baikeinfo_btn_yuanlingyongtu.getText().toString());
                intent11.putExtra("content",yuanlingyongtu);
                startActivity(intent11);
                break;
            case R.id.baikeinfo_btn_wenhuabeijing:
                Intent intent12 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent12.putExtra("title",baikeinfo_btn_wenhuabeijing.getText().toString());
                intent12.putExtra("content",wenhuabeijing);
                startActivity(intent12);
                break;
            case R.id.baikeinfo_btn_huayu:
                Intent intent13 = new Intent(BaiKeInfoActivity.this,BaiKeInfoToDetailsActivity.class);
                intent13.putExtra("title",baikeinfo_btn_huayu.getText().toString());
                intent13.putExtra("content",huayu);
                startActivity(intent13);
                break;
        }
    }

    @Override
    void initDate() {
        GetBaiKeInfoModel getBaiKeInfoModel = new GetBaiKeInfoModel();
        getBaiKeInfoModel.getBaiKeInfo(enc_id, new TListener<BaiKeBean>() {
            @Override
            public void onResponse(BaiKeBean baiKeBean) {
                   jieshao = baiKeBean.getEnc_introduce();
                   xingtaitezhen = baiKeBean.getEnc_form();
                   shengtaixixing = baiKeBean.getEnc_habit();
                   zaipeijishu = baiKeBean.getEnc_cultivate();
                   yangzhifangfa = baiKeBean.getEnc_breed();
                   fanzhifangshi = baiKeBean.getEnc_reproduction();
                   binghaifangzhi = baiKeBean.getEnc_disease();
                   pingzhongfenlei = baiKeBean.getEnc_varieties();
                   fenbuquyu = baiKeBean.getEnc_purpose();
                   zuoyongyongtu = baiKeBean.getEnc_effect();
                   yuanlingyongtu = baiKeBean.getEnc_gardens();
                   wenhuabeijing = baiKeBean.getEnc_culture();
                   huayu = baiKeBean.getEnc_moral();

                   baikeinfo_name.setText(baiKeBean.getEnc_name());
                   String img = Service.BASE_URL+"flower_impression/public/uploads/"+baiKeBean.getEnc_photo();
                   Picasso.with(BaiKeInfoActivity.this).load(img).into(baikeinfo_img);
                   baikeinfo_bieming.setText(baiKeBean.getEnc_alias());
                   baikeinfo_fenlei.setText(baiKeBean.getEnc_typename());
                   baikeinfo_shenghuaqi.setText(baiKeBean.getEnc_florescence());
                   baikeinfo_keshu.setText(baiKeBean.getEnc_secname());
                   baikeinfo_jiejian.setText(baiKeBean.getEnc_introduce());
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }
}
